package com.egao.orderB.service.impl;

import com.egao.common.core.damon.results.PageResult2;
import com.egao.common.core.web.JsonResult;
import com.egao.common.system.entity.User;
//import com.egao.orderB.mapper.BillFeeWriteOffItemMapper;
import com.egao.orderB.entity.BillFeeWriteOffItem;
import com.egao.orderB.service.BillFeeWriteOffItemService;
import org.springframework.stereotype.Service;
import com.egao.orderB.biz.BillFeeWriteOffItemBiz;
import net.sf.json.JSONObject;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
//import javax.transaction.Transactional;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 销账列表的销账记录服务实现类
 * @author : Doman
 * @date : 2021-04-19 17:05:50
 * @version ：1.0
 */
@Service
public class BillFeeWriteOffItemServiceImpl /*extends ServiceImpl<BillFeeWriteOffItemMapper, BillFeeWriteOffItem> */implements BillFeeWriteOffItemService {

	@Autowired
	private BillFeeWriteOffItemBiz billFeeWriteOffItemBiz;

    /**
    @Override
    public PageResult<BillFeeWriteOffItem> listPage(PageParam<BillFeeWriteOffItem> page) {
        List<BillFeeWriteOffItem> records = baseMapper.listPage(page);
        return new PageResult<>(records, page.getTotal());
    }

    @Override
    public List<BillFeeWriteOffItem> listAll(Map<String, Object> page) {
        return baseMapper.listAll(page);
    } */

    @Override
    public JsonResult list(PageResult2<T> page, BillFeeWriteOffItem billFeeWriteOffItem, User loginUser)  throws Exception{
        return billFeeWriteOffItemBiz.list(page,billFeeWriteOffItem,loginUser);
    }

    @Override
    public JsonResult list(BillFeeWriteOffItem billFeeWriteOffItem, User loginUser) {
        return JsonResult.ok().setData(billFeeWriteOffItemBiz.list(billFeeWriteOffItem,loginUser));
    }

    @Override
    public JsonResult getById(BillFeeWriteOffItem billFeeWriteOffItem) {
        return JsonResult.ok().setData(billFeeWriteOffItemBiz.getById(billFeeWriteOffItem));
    }

    @Transactional
    @Override
    public JsonResult save(BillFeeWriteOffItem billFeeWriteOffItem, User loginUser) {
        if (billFeeWriteOffItemBiz.save(billFeeWriteOffItem, loginUser)) {
            return JsonResult.ok("添加成功");
        }
        return JsonResult.error("添加失败");
    }

    @Transactional
    @Override
    public JsonResult update(BillFeeWriteOffItem billFeeWriteOffItem, User loginUser) {
        if (billFeeWriteOffItemBiz.update(billFeeWriteOffItem, loginUser)) {
            return JsonResult.ok("修改成功");
        }
        return JsonResult.error("修改失败");
    }

    @Transactional
    @Override
    public JsonResult remove(BillFeeWriteOffItem billFeeWriteOffItem, User loginUser) {
        if (billFeeWriteOffItemBiz.remove(billFeeWriteOffItem, loginUser)) {
            return JsonResult.ok("删除成功");
        }
        return JsonResult.error("删除失败");
    }

}
